<table class="admingrid" id="usefullinks">
</table>
<button onclick="addUsefulLink()">Add useful link</button>
<button onclick="changeUsefullink()">Change useful link</button>
<button onclick="removeUsefulLink()">Remove useful link</button>

<script>
grids.usefullinks = {
    url : generateServiceUrl({
        admin : true,
        service : "getlinkgroup",
        page : "static_content",
        params : {
            linkgroup : "usefullinks"
        }
    }),
    colNames : [
        "href",
        "title"
    ],
    colModel : [
        { name : "href",   index : "href",   width : 350 },
        { name : "title",  index : "title",  width : 350 }
    ],
    caption : "Useful links",
    multiselect : true,
    multiboxonly : true,
    sortable : true
};

function reorder_usefullinks(idlist) {
    callAdminService("static_content", "reorder", {
        idlist : idlist,
        groupname : "usefullinks"
    }, {
        success : function() { }
    });
}


function changeUsefullink() {
    var id = getSelectedRow("usefullinks");
    openAdminPopup("static_content", "changepopup", {
        title : "Change useful link"
    }, {
        groupname : "usefullinks",
        id : id
    });
}

function addUsefulLink() {
    openAdminPopup("static_content", "addpopup", {
        title : "Adding new link"
    }, {
        groupname : "usefullinks"
    });
}

function removeUsefulLink() {
    if (confirm("Are you sure to want to delete selected link?")) {
        var selectedItems = getSelectedRows("usefullinks");
        callAdminService("static_content", "deletelinkfromgroup", {
            ids : selectedItems,
            groupname : "usefullinks"
        }, {
            success : function(result) {
                refreshGrid("usefullinks");
            }
        });
    }
}

</script>
